package flower.com.a600_xm.ui;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;


import java.util.ArrayList;
import java.util.List;

import flower.com.a600_xm.R;


/**
 * Created by Haoz on 2017/4/6 0006.
 */

/**
 * 检查更新时有新版本发布弹出对话框
 * Created by zhyh on 2015/11/16.
 */
public class NewVersionDialogFragment extends DialogFragment {
    private String mVersionCode;
    private String mDescription;
    private OnUpdateListener mOnUpdateListener;

    public void setOnUpdateListener(OnUpdateListener onUpdateListener) {
        mOnUpdateListener = onUpdateListener;
    }

    public interface OnUpdateListener {
        void onUpdate(String name, String sex, String age, String Medical_history, String tele);
    }

    public static NewVersionDialogFragment newInstance(String versionCode, String description) {
        NewVersionDialogFragment fragment = new NewVersionDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putString("version", versionCode);
        bundle.putString("description", description);
        fragment.setArguments(bundle);
        return fragment;
    }

    List<String> ccList;
    StringBuilder stringBuilder;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        mVersionCode = bundle.getString("version");
        mDescription = bundle.getString("description");
        ccList = new ArrayList<String>();
        stringBuilder = new StringBuilder();

    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return super.onCreateDialog(savedInstanceState);
    }

//    String sexvalue = "男";
//    EditText ed_name;
//    EditText ed_age;
//    EditText ed_bingshi;
//    boolean xie = false;
//    ImageView imageView10;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.dialog_news, null);
        RelativeLayout bt_zfb = (RelativeLayout) view.findViewById(R.id.bt_zfb);
        bt_zfb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getActivity(), "支付宝支付", Toast.LENGTH_SHORT).show();
                dismiss();
            }
        });
        RelativeLayout bt_wx = (RelativeLayout) view.findViewById(R.id.bt_wx);
        bt_wx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                Toast.makeText(getActivity(), "微信支付", Toast.LENGTH_SHORT).show();

            }
        });
//        ed_bingshi = (EditText) view.findViewById(R.id.ed_bingshi);
//        imageView10 = (ImageView) view.findViewById(R.id.imageView10);
//        imageView10.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                dismiss();
//            }
//        });
//        ed_bingshi.addTextChangedListener(mTextWatcher);
//        final EditText ed_tele = (EditText) view.findViewById(R.id.ed_tele);


        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        Dialog dialog = getDialog();
        if (dialog != null) {
            DisplayMetrics dm = new DisplayMetrics();
            getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
            dialog.getWindow().setLayout((int) (dm.widthPixels * 0.75), (int) (dm.heightPixels * 0.75));
        }
    }


}


